<template>
  <van-notify v-model="visibleShow" position="top">
    <div class="loading" v-if="loading">
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
    </div>
    <div class="loadmes" v-else>
      <div class="icon" v-if="iconShow">
        <slot name="iconOk"></slot>
        <slot name="iconErr"></slot>
      </div>
      <p>{{ title }}</p>
    </div>
  </van-notify>
</template>

<script>
export default {
  name: 'lNotify',
  data () {
    return {}
  },
  props: {
    // 是否显示弹窗
    visible: {
      type: Boolean
    },
    // 是否显示消息通知 加载动画
    loading: {
      type: Boolean,
      default: true
    },
    // 是否显示消息通知  图标
    iconShow: {
      type: Boolean,
      default: true
    },
    // 是否显示消息通知 内容
    title: {
      type: String,
      default: ''
    }
  },
  computed: {
    visibleShow: {
      get () {
        return this.visible
      },
      set (val) {
        return this.$emit('visibleShow', val)
      }
    }
  }
}
</script>

<style lang="less" scoped>
.van-notify {
  position: absolute;
  background-color: #ffffff;
    width: 70%;
    height: 60px;
    border-radius: 20px;
    left: 16%;
    top: 15px;
    box-shadow: 0px 0px 26px -12px #646566;
  // 登录信息通
}

// 登录中加载动画
.loading {
  // display: block;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 20px;
  margin: auto;
  text-align: center;
  position: relative;
  span {
    display: inline-block;
    width: 8px;
    height: 6px;
    border-radius: 4px;
    // background-color: #6ed9a2;
    margin: 0 2px;
    animation: load 1s ease infinite;
  }

  @keyframes load {
    0%,
    100% {
      transform: scaleY(3.5);
      border-radius: 8px;
      background-color: #ff8700;
    }

    50% {
      transform: scaleY(1);
      border-radius: 6px;
      background-color: #6ed9a2;
    }
  }

  span:nth-child(2) {
    animation-delay: 0.2s;
  }

  span:nth-child(3) {
    animation-delay: 0.4s;
  }

  span:nth-child(4) {
    animation-delay: 0.6s;
  }

  span:nth-child(5) {
    animation-delay: 0.8s;
  }
}

// 登录成功/失败的显示
.loadmes {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  /deep/.van-icon {
    color: #6ed9a2;
    font-size: 36px;
  }
  p {
    color: black;
    padding-left: 27px;
    font-weight: 550;
    font-size: 16px;
  }
}
</style>
